/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.asu.cse360.editor;

import java.beans.PropertyEditorSupport;
import org.joda.time.DateTime;


public class DateTimePropertyEditor extends PropertyEditorSupport {

    @Override
    public void setAsText(String text){
        setValue(buildDate(text));
    }

    public static DateTime buildDate(String text){
        String[] parts = text.split("@");
        String[] dateParts = parts[0].split("-");
        String[] timeParts = parts[1].split(":");
        int year = Integer.valueOf(dateParts[2]);
        int month = Integer.valueOf(dateParts[0]);
        int day = Integer.valueOf(dateParts[1]);
        int hour = Integer.valueOf(timeParts[0]);
        int minute = Integer.valueOf(timeParts[1]);
        int second = Integer.valueOf(timeParts[2]);
        return new DateTime(year, month, day, hour, minute, second, 0);
    }

}
